package cn.iotab.iotkit.server.demo.device.handler.firmware;

import cn.iotab.iotkit.transport.api.access.device.listener.firmware.DeviceReportFirmwareListener;
import cn.iotab.iotkit.transport.api.access.model.custom.firmware.ReportFirmwareMessage;
import cn.iotab.iotkit.transport.api.access.model.message.DeviceMessageReply;
import cn.iotab.iotkit.transport.api.common.util.JsonUtil;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 设备上报固件信息
 * <pre>
 * {
 *     "id":"123",
 *     "ver":"1.0",
 *     "ack":0,
 *     "type":"firmware.report",
 *     "param":{
 *         "version":"1.2.3",
 *         "properties":{
 *             "aa":"bb",
 *             "cc":"dd"
 *         }
 *     }
 * }
 * </pre>
 */
@Slf4j
@Component
public class MyDeviceReportFirmwareListener extends DeviceReportFirmwareListener {

    @Override
    protected ListenableFuture<DeviceMessageReply> doProcess(ReportFirmwareMessage message) {
        log.info("收到设备上报固件信息：{}", JsonUtil.toJsonString(message));
        return null;
    }
}
